|
Working with styles
The detailed description of styles can be found in the corresponding chapter. First of all, let us call to mind, what “style”, “set of styles” and “library of styles” are. Style is an element, which possesses a name and properties, and determines design attributes, i.e. color, font and frame. The style determines the way a report object should be designed. The objects such as TfrxMemoView have the Style property, which is a property intended to set the style name. When applying a value to this property, the style design attributes are copied to the object. A set of styles consists of several styles, which refer to a report. The “TfrxReport” component has the “Styles” property, which refers to the object of the “TfrxStyles” type. The set of styles also possesses a name. The set of styles determines design of a whole report. A styles library includes several sets of styles. It is convenient to perform a selection of a concrete set for report design with the help of the library. The TfrxStyleItem represents a style. TfrxStyleItem = class (TCollectionItem) public Style name. property Color: TColor; Background color. property Font: TFont; Font. property Frame: TfrxFrame; Frame. end; The set of styles is represented by the TfrxStyles class. It comprises methods for performing such set operations as reading, saving, adding, deleting, as well as searching for a style. The set of styles file has FS3 extension by default. TfrxStyles = class (TCollection) public Creates the styles set. One can specify “nil” instead of “AReport,” however in this case a user would be unable to use the “Apply” method. function Add: TfrxStyleItem; Adds a new style. function Find( const Name: String ): TfrxStyleItem; Returns the style with the given name. procedure Apply; Applies a set to a report. procedure GetList(List: TStrings); Returns the list of the styles names. procedure LoadFromFile( const FileName: String ); procedure LoadFromStream(Stream: TStream); Reads a set. procedure SaveToFile( const FileName: String ); procedure SaveToStream(Stream: TStream); Saves a set. property Items[Index: Integer]: TfrxStyleItem; default; The list of styles. property Name: String; A set’s name. end; In conclusion, the last “TfrxStyleSheet” class represents a styles’ library. It has methods for the library reading/saving, as well as adding, deleting, and style sets’ searching. TfrxStyleSheet = class (TObject) public Constructs a library. procedure Clear; Clears a library. procedure Delete(Index: Integer); Deletes a set with certain number. procedure GetList(List: TStrings); Returns the list of the names of styles’ sets. procedure LoadFromFile( const FileName: String ); procedure LoadFromStream(Stream: TStream); Loads a library. procedure SaveToFile( const FileName: String ); procedure SaveToStream(Stream: TStream); Saves a library. function Add: TfrxStyles; Adds a new set of styles to the library. function Count: Integer; Returns a number of styles’ sets in the library. function Find( const Name: String ): TfrxStyles; Returns a set with the set name. function IndexOf( const Name: String ): Integer; Returns a set number with the given name. property Items[Index: Integer]: TfrxStyles; default; The list of styles’ sets. end; |